package org.hs.phd.odi.tracking.tracker;

import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.util.Arrays;

public final class TrackerUtils {

	
	private static final float EPSILON = 0.0000000001F;

	private TrackerUtils(){}
	
	public static Polygon getCopy(Polygon polygon) {
		int[] xpoints = Arrays.copyOf(polygon.xpoints, polygon.npoints);
		int[] ypoints = Arrays.copyOf(polygon.ypoints, polygon.npoints);

		return new Polygon(xpoints, ypoints, polygon.npoints);
	}

	
	public static Polygon getAsPolygon(Rectangle rect ) {
		Polygon result = new Polygon();
        result.addPoint(rect.x, rect.y);
        result.addPoint(rect.x + rect.width, rect.y);
        result.addPoint(rect.x + rect.width, rect.y + rect.height);
        result.addPoint(rect.x, rect.y + rect.height);
        return result;	
	}

	public static void printArray(String title, float[] data) {
		System.out.print(title + ": \n\t [");
		for(int i = 0; i < data.length; i++){
			System.out.print(data[i] + ", ");
		}
		System.out.println("]");
	}

	public static void printArrayNonZeroes(String title, float[] data) {
		System.out.print(title + ": \n\t [");
		for(int i = 0; i < data.length; i++){
			if(data[i] > EPSILON )
			System.out.print( "(["+ i + "]" + data[i] + ") ");
		}
		System.out.println("]");
	}


}
